<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home></home>
  </div>
  <script src="./vue.js"></script>
  <script>
    const Home = {
      template: `
        <div>
          <h2>home组件</h2>
          <button ref="btn">按钮</button>  
        </div>
      `,
      data(){
        return {
          msg: '你好世界'
        }
      },
      beforeCreate(){
        console.log('实例初始化完成之前--beforeCreate');
        console.log(this.msg);
      },
      created(){
        console.log('实例初始化完成--created');
        console.log(this.msg);
      },
      beforeMount(){
        console.log('组件template编译之前--beforeMount');
        console.log(this.$refs.btn);
      },
      mounted(){
        console.log('template已经编译完成--mounted');
        console.log(this.$refs.btn);
      },
      beforeUpdate(){
        console.log('视图更新之前--beforeUpdate');
      },
      updated(){
        console.log('视图已经更新完成--updated');
      },
      beforeDestroy(){
        console.log('实例销毁之前--beforeDestroy');
      },
      destroyed(){
        console.log('实例已经销毁--destroyed');
      }
    }
    Vue.component('Home', Home)
    const vm = new Vue({
      el: '#app'
    })
  </script>
</body>
</html>